package sis.utiltest;/*
* @auther 顶风少年 
* @mail dfsn19970313@foxmail.com
* @date 2019-08-03 11:03
* @notify 
* @version 1.0
*/

import junit.framework.TestCase;
import sis.util.EventMap;

import java.util.List;

public class EventMapTest extends TestCase {
    public void testSingleElement(){
        EventMap<java.sql.Date,String> map = new EventMap<>();
        final java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
        final String value = "abc";
        map.put(date,value);
        List<String> values = map.get(date);
        assertEquals(value,values.get(0));
    }

    public void testGetPastEvents(){
        EventMap<java.util.Date,String> events = new EventMap<java.util.Date,String>();
        final java.util.Date today = new java.util.Date();
        final java.util.Date yesterday = new java.util.Date(today.getTime()-86400000);
        events.put(today,"sleep");
        final String descriptionA = "birthday";
        final String descriptionB = "drink";

        events.put(yesterday,descriptionA);
        events.put(yesterday,descriptionB);
        events.put(yesterday,descriptionB);
        List<String> descriptions = events.getPastEvents();
        for (String s:descriptions){
            System.out.println(s);
        }
        assertTrue(descriptions.contains(descriptionA));
        assertTrue(descriptions.contains(descriptionB));
    }
}
